package com.springbootstudy.demo.web;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/Query")
public class QueryController {
    private static Logger log = LoggerFactory.getLogger(QueryController.class);

    @Autowired
    private com.springbootstudy.demo.test.Student Student;
    @Autowired
    private com.springbootstudy.demo.test.Student2 Student2;

    @ResponseBody
    @RequestMapping("/query")
    public String toIndex() {

        log.error("发生异常了");
        log.info("没事，一切正常");


        return "aa";
    }

    @ResponseBody
    @RequestMapping("/bean2")
    public String bean(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.getRequestDispatcher("/templates/login.html").forward(request, response);

        return "111" ;
    }
    @RequestMapping("/query2")
    public String toIndex2() {

        log.error("发生异常了");



        return "aa";
    }
//    @ResponseBody
//    @RequestMapping("/query3")
//    public Object toIndex3() {
//
//        log.error("发生异常了1111");
//
//
//
//        return Student;
//    }
    @ResponseBody
    @RequestMapping("/query4")
    public Object toIndex4() {

        log.error("发生异常了1111");
//        Object commonYml = PropertiesUtils.getCommonYml("application-cc.yml", "student.name");
//
//        Object commonYml2 = PropertiesUtils.getCommonYml("application-cc.yml", "student2.name");
        return Student;
    }
}
